/**
 * Created by yubaolin on 2017/9/20.
 */
import ajax from '../ajax'

export default {
  getCategoryTree (success, fail = null) {
    ajax.get({url: '/api/category/categoryTree', success, fail})
  },
  saveCategory (category, success, fail = null) {
    const method = category.id === 0 ? 'post' : 'put'
    ajax[method]({url: `/api/category/${category.id}`, data: category, success, fail})
  },
  deleteCategory (id, success, fail = null) {
    ajax.del({url: `/api/category/${id}`, success, fail})
  },
  deleteCategoryList (ids, success, fail = null) {
    ajax.del({url: `/api/category/deleteList`, data: {ids}, success, fail})
  }
}
